<?php
class LeksModel extends Model {
	
	public function getAllLeks($wsId) {
		$leks = array();
		$result = $this->selectAllIds('leks', 'id_website = '. $wsId . ' ORDER BY `id` DESC');
		foreach ($result as $row) {
			$leks[] = new Leksem($row->id);
		}
		return $leks;
	}
	
	public function getAllDict() {
		$dict = array();
		$result = $this->selectAllIds('dictionary');
		foreach ($result as $row) {
			$dict[] = new Dictionary($row->id);
		}
		return $dict;
	}
	
	public function isLeksNameExists($leksName) {
		$queryString = sprintf("
			SELECT 
				`leks`.`id`
			FROM 
				`leks`
			WHERE 
				`leks`.`name` = '%s'	
		", $leksName);
		$result = $this->_sqlInstance->query($queryString);
		return empty($result) ? 0 : 1;
	}
}